﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<c:set var="path" value="${pageContext.request.contextPath }" />
<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>变频器维保记录录入</title>
	<meta name="viewport"  content="width=device-width, initial-scale=1">
	<link rel="stylesheet" type="text/css" href="${path}/resource/plugins/bootstrap/css/bootstrap.min.css">
  	<link rel="stylesheet" type="text/css" href="${path}/resource/plugins/bootstrap/css/bootstrap-multiselect.css">
  	<link rel="stylesheet" type="text/css" href="${path}/resource/css/ysrmain.css">
    <link rel="stylesheet" href="${path}/resource/css/gzfx.css">	    
    <link rel="stylesheet" href="${path}/resource/css/records.css">
    <link rel="stylesheet" type="text/css" href="${path}/resource/plugins/date/bootstrap-datetimepicker.min.css" >
    <script type="text/javascript" src="${path}/resource/plugins/jQuery/jquery-2.2.3.min.js"></script>
	<script type="text/javascript" src="${path}/resource/plugins/bootstrap/js/bootstrap.min.js"></script>
	<script type="text/javascript" src="${path}/resource/plugins/bootstrap/js/bootstrap-multiselect.js"></script>
	<script src="${path}/resource/plugins/date/bootstrap-datetimepicker.min.js" charset="UTF-8"></script>
	<script src="${path}/resource/plugins/date/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
	<script type="text/javascript" src="${path}/resource/js/echarts.min.js"></script>
	<style type="text/css">
		.text-btn input{
			width:69%;
		}
		.text-btn a{
			margin-left:20px;
		}
	</style>
</head>
<body>
	
	<!-- 头部 -->
	<!-- 开始 -->
	<jsp:include page="./top_nav.jsp"></jsp:include>
	<!-- 头部结束 -->
	
	
	
    <!-- 右侧内容区域 -->
    <div class="right-content container-fluid ">
    	<div class="row">
    		<!-- 主要图表区域 -->
            
   		<div class="head-w">变频器维保记录录入</div>
   		<div class="cont-condition">
   		
   			<form id="dataForm" class="">
   				<div class="form-horizontal">
				  	<div class="div-group5">
					    <label class="g-label">故障日期:</label>
					    <div class="g-input">
					    	 <input name="startTime" type="text" data-link-format="yyyy-mm-dd" data-link-field="dtp_input2" placeholder="请选择开始日期" class="form_date time-input2 input-text" id="datetimepicker1" data-date-format="yyyy-mm-dd ">	
			     		   	<span class="span-date"><span class="glyphicon glyphicon-calendar"></span></span>
					    </div>
				  	</div>
				  	<div class="div-group5">
					    <label class="g-label">出厂序号:</label>
					    <div class="g-input">
					    	<select id="serialNum" name="serialNum">
					    		<option value=""></option>
					    	</select>
					    </div>
				  	</div>
				  	<div class="div-group5">
					    <label class="g-label">产品型号:</label>
					    <div class="g-input">
					    	<input readonly="readonly" placeholder="请检查出厂序号" id="powerLevelType" type="text" class="input-text">
					    </div>
				  	</div>
				  	<div class="div-group5">
					    <label class="g-label">安装城市:</label>
					    <div class="g-input">
					    	<input readonly="readonly" placeholder="请检查出厂序号" id="cityArea" type="text" class="input-text">
					    </div>
				  	</div>
				  	<div class="div-group5">
					    <label class="g-label">故障数量:</label>
					    <div class="g-input">
					    	<input name="faultNum" type="text" class="input-text">
					    </div>
				  	</div>
				  	<div class="div-group5">
					    <label class="g-label">完成日期:</label>
					    <div class="g-input">
					    	<input name="endTime" type="text" readonly="readonly" data-link-format="yyyy-mm-dd" data-link-field="dtp_input2" placeholder="请选择结束日期" class="form_date time-input2 input-text" id="datetimepicker2" data-date-format="yyyy-mm-dd ">
			     			<span class="span-date"><span class="glyphicon glyphicon-calendar"></span></span>
					    </div>
				  	</div>
				  	<div class="div-group5">
					    <label class="g-label">所属部件:</label>
					    <div class="g-input">
					    	<select id="belongPart" name="belongPart" multiple="multiple">
					    		
					    		<option value="功率模块">功率模块</option>
								<option value="控制系统">控制系统</option>
								<option value="变流器其他">变流器其他</option>
					    	</select>
					    </div>
				  	</div>
				  	<div class="div-group5">
					    <label class="g-label">故障零件:</label>
					    <div class="g-input">
					    	<select id="faultElement" name="faultElement" multiple="multiple">
					    		<option value="">—请选择—</option>
					    	</select>
					    </div>
				  	</div>
				  	<div class="div-group5">
					    <label class="g-label">故障代码 :</label>
					    <div class="g-input">
					    	<select id="faultCode" name="faultCode" multiple="multiple">
					    		<option value="">—请选择—</option>
					    	</select>
					    </div>
				  	</div>
				  	<div class="div-group5">
					    <label class="g-label">故障工况:</label>
					    <div class="g-input">
					    	<select name="faultPhase">
					    		<option value="">—请选择—</option>
								<option value="未上电">未上电</option>
								<option value="初始化">初始化</option>
								<option value="充电合主断">充电合主断</option>
								<option value="待机状态">待机状态</option>
								<option value="运行工况">运行工况</option>
					    	</select>
					    </div>
				  	</div>
				  	<div class="div-group5">
					    <label class="g-label">投运日期:</label>
					    <div class="g-input">
					    	 <input readonly="readonly" placeholder="请检查出厂序号" id="operationDate" type="text" class="input-text">
			     		     <span class="span-date"><span class="glyphicon glyphicon-calendar"></span></span>
					    	
					    </div>
				  	</div>
				  	<div class="div-group5">
					    <label class="g-label">处理结果:</label>
					    <div class="g-input">
					    	<select name="processRes">
					    		<option value="">—请选择—</option>
								<option value="故障消除">故障消除</option>
								<option value="故障依旧">故障依旧</option>
								<option value="观察运行">观察运行</option>
					    	</select>
					    </div>
				  	</div>
				  	<div class="div-group5">
					    <label class="g-label">服务类型:</label>
					    <div class="g-input">
					    	<select name="serverType">
					    		<option value="">—请选择—</option>
								<option value="安装">安装</option>
								<option value="调试">调试</option>
								<option value="三包维护">三包维护</option>
								<option value="有偿服务">有偿服务</option>
					    	</select>
					    </div>
				  	</div>
				  	<div class="div-group5">
					    <label class="g-label">问题类别:</label>
					    <div class="g-input">
					    	<select name="faultType">
					    		<option value="">—请选择—</option>
								<option value="设计问题">设计问题</option>
								<option value="工艺制造">工艺制造</option>
								<option value="供应质量">供应质量</option>
								<option value="系统问题">系统问题</option>
								<option value="包装运输">包装运输</option>
								<option value="操作维护">操作维护</option>
								<option value="其他">其他</option>
					    	</select>
					    </div>
				  	</div>
				  	<div class="div-group5">
					    <label class="g-label">售后人员:</label>
					    <div class="g-input">
					    	<select name="repairman">
					    		<option value="">—请选择—</option>
								<option value="李易(20129070)">李易(20129070)</option>
								<option value="李军伟(20080267)">李军伟(20080267)</option>
								<option value="邓德新(20121667)">邓德新(20121667)</option>
								<option value="陈昌佳(20105321)">陈昌佳(20105321)</option>
								<option value="何林桂(20101112)">何林桂(20101112)</option>
					    	</select>
					    </div>
				  	</div>
				  	
			</div>
			<div class="text-info">
			    <div class="form-group">
				   <textarea name="faultDesc" class="" rows="3" placeholder="请描述故障现象："></textarea>
				</div>
			</div>
			<div class="text-info">
			    <div class="form-group">
				   <textarea name="processMeth" class="" rows="3" placeholder="请描述处理措施："></textarea>
				</div>
			</div>
			<div class="text-info">
			    <div class="form-group">
				   <textarea name="faultCause" class="" rows="3" placeholder="请描述故障原因："></textarea>
				</div>
			</div>
			<div class="text-info">
			    <div class="form-group">
				   <textarea name="remark" class="" rows="3" placeholder="请描述备注信息："></textarea>
				</div>
			</div>
			<div class="text-btn">
				<label class="pull-left" for="">详细地址:</label>
				<input readonly="readonly" class="pull-left" placeholder="请检查出厂序号" id="locationDetail">
				<a class="pull-right" href="${path}/monitor/redirect/repairManage">取消 </a>
				<button class="pull-right" type="button" onclick="newAdd();">录入</button>
				
			</div>
			</form>
   		</div>
   		
   
	   </div>
    </div>
</body>
<script type="text/javascript">
$(function(){
	/*左侧nav选中状态*/
	$(".menu-left").children("dl").eq(2).addClass("dl-active");
	//加载序列号下拉框
	loadSelect();
	/*时间组件初始化*/
	$(".span-date").click(function(){		
		$(this).prev().focus();
	})
	/*多选初始化*/
	$(document).ready(function() {
        
        $('#belongPart').multiselect({
       	 buttonWidth: '90%',
       	 buttonClass:'back-m1 color-w',
       	 
       	 nonSelectedText:'—请选择—',
       });
        $('#faultElement').multiselect({
          	 buttonWidth: '90%',
          	 buttonClass:'back-m1 color-w',
          	 nonSelectedText:'—请选择—',
        });
        $('#faultCode').multiselect({
       	 buttonWidth: '90%',
       	 buttonClass:'back-m1 color-w',
       	 nonSelectedText:'—请选择—',
       });
    });
	$('.form_date').datetimepicker({
	    language:  'zh-CN',
	    weekStart: 1,
	    todayBtn:  1,
		autoclose: 1,
		todayHighlight: 1,
		startView: 2,
		minView: 2,
		forceParse: 0,
		maxView:4
	});
})

//加载下拉框
function loadSelect() {
	$.ajax({
		type : 'POST',
		url : '<%=path%>/manage/initopt',
		data : {
			opttype : 'serialNum'
		},
		dataType : 'json',
		async : false,
		success : function(result) {
			if(result.status == 'OK') {console.log(result);
				var html = '<option value="">—请选择—</option>';
				var ops = eval("(" + result.data.serialNum + ")");
				$.each(ops, function(i) {
					html += ops[i].value;
				});
				$('#serialNum').html('');
				$('#serialNum').append(html);
			} else {
				console.error("获取下拉框数据失败！");
			}
		},
		error : function() {
			console.error("系统错误！");
		}
	});
}
//选择序列号
$('#serialNum').change(function() {
	if($(this).val() != "") {
		$.ajax({
			type : 'POST',
			url : '<%=path%>/manage/managerdevdetail',
			data : {
				serialNum : $(this).val()
			},
			dataType : 'json',
			async : false,
			success : function(result) {
				if(result.status == 'OK') {console.log(result);
					$('#powerLevelType').val(result.data.powerLevelType);
					$('#cityArea').val(result.data.cityArea);
					$('#locationDetail').val(result.data.locationDetail);
					$('#operationDate').val(result.data.operationDate);
					if(result.data.powerLevelType != undefined && result.data.powerLevelType != "") {
						$.ajax({
							type : 'POST',
							url : '<%=path%>/manage/sltoptupdate',
							data : {
								opttype : 'faultCode',
								actval : result.data.powerLevelType
							},
							dataType : 'json',
							async : false,
							success : function(result2) {
								if(result2.status == 'OK') {console.log(result2);
									var html = '';
									var ops = eval("(" + result2.data.faultCode + ")");
									$.each(ops, function(i) {
										html += ops[i].value;
									});
									$('#faultCode').html('');
									$('#faultCode').append(html);
									$('#faultCode').multiselect('rebuild');
								}
							}
						});
					}
				} else {
					console.error("获取设备详情数据失败！");
				}
			},
			error : function() {
				console.error("系统错误！");
			}
		});
	} else {
		$('#powerLevelType').val('');
		$('#cityArea').val('');
		$('#locationDetail').val('');
		$('#operationDate').val('');
		$('#faultCode').html('<option value="">—请选择—</option>');
		$('#faultCode').multiselect('rebuild');
	}
});
//选择所属部件,加载故障零件下拉框
$('select[name="belongPart"]').change(function() {
	if($(this).val() != "" && $(this).val() != null) {
		var val = $(this).val().join(",");
		$.ajax({
			type : 'POST',
			url : '<%=path%>/manage/sltoptupdate',
			data : {
				opttype : 'faultElement',
				actval : val
			},
			dataType : 'json',
			async : false,
			success : function(result) {
				if(result.status == 'OK') {console.log(result);
					var html = '';
					var ops = eval("(" + result.data.faultElement + ")");
					$.each(ops, function(i) {
						html += ops[i].value;
					});
					$('#faultElement').html('');
					$('#faultElement').append(html);
					$('#faultElement').multiselect('rebuild');
					
				} else {
					console.error("获取下拉框数据失败！");
				}
			},
			error : function() {
				console.error("系统错误！");
			}
		});
	} else {
		$('#faultElement').html('<option value="">—请选择—</option>');
		$('#faultElement').multiselect('rebuild');
	}
});

function newAdd() {
	$.ajax({
		type : 'POST',
		url : '<%=path%>/manage/firstmatainAdd',
		data : $('#dataForm').serialize(),
		dataType : 'json',
		async : false,
		success : function(result) {
			if(result.status == 'OK') {
				if(result.data != null && result.data != "" && result.data != "null") {
					alert("新增成功！");
					window.location.href = '${path}/monitor/redirect/repairManage';
				} else {
					alert("新增失败！");
				}
			} else {
				alert("新增失败！");
			}
		}
	});
}
</script>
</html>